<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE HTML>
<%-- <%@include file="edit.jsp"%> --%>
<html>
<head>
<script type="text/javascript">
	$(function(){
		$("#file_upload_img").on('click',function(){
			toDeploy("jpg,png",false);
		});
		
		$("#file_upload_Othere").on('click',function(){
			toDeploy("jpg,png",true);
		});
		var fileIds =[];
		var filesUrl = [];
		//添加界面的附件管理
		function toDeploy(extensions,isSelection){
			showUpload({title:'上传文件'
				,options:{
					filters:{
						mime_types: [{title : "封面", extensions : extensions}]
					},
					multi_selection: isSelection,
					 init:{
						 FileUploaded:function(uploader,file,responseObject){
							 var response = responseObject.response;
							 var json = eval('(' + response + ')');
							 var data = json.data;
							 var path = data.fileUrl;
							 fileIds.push(data.id);
							 filesUrl.push(data.path);
							 $("#img_id").val(data.id);  //完成后更新已上传的文件列表
							 $("#cover_url").val(path);  //封面url
							 $("#td_showFiles").append('</br>'+path);
							 showImg(path);
						 }
					},
					complete:function(){
						top.$ok('上传成功');
					}
				}
			});
		}
		function showImg(path){
			var html = '<img src="'+path+'" style="width:60px;heigth:60px;">';
			$("#td_showImg").html(html);
		}
		$("#save_tag").click(function(){
			var ids = fileIds.join(",");
			$("#input_fileIds").val(ids);
			var isValid = $('#dataform').form('enableValidation').form('validate');
			
			
			
			if(!isValid){
				top.$prompt('请完善项目信息');
				return;
			}
			toSave();
		});
		function toSave(){
			$.messager.progress({title:'系统提示',text:'数据处理中，请耐心等待...'});
			$.submit('#dataform',function(r) {
				$.messager.progress('close');
				if(r.code<0) return $alert(r.msg);
				top.$prompt('保存成功');
				top.$window.close(window,1,null);
			});
		}
		
		//标签
		$('#comb_pid').combotreegrid({
       		width:'100%',
        	url:'treeModel',
        	method:'post',
        	idField:'id',
        	treeField:'tagName',
        	fitColumns:true,
        	panelHeight:300,
        	columns:[[
            	{field:'tagName',title:'名称'},
        		{field:'tagType',title:'类型',align:'center',formatter:function(v,r,i){
        			var type = "标签";
        			if(r.tagType =="1"){
        				type = "栏目";
        			}
        			return type;
        		}},
        		{field:'tagNote',title:'备注 '},
        		{field:'createdDt',title:'创建时间'},
        	]]
    	});
		
	});

</script>
<body>
	
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center',border:false">
			<form id="dataform" action="add" method="post">
				<input type="hidden" id="input_fileIds" name = "fileIds">
				<table class="form-tbl" cellpadding="5" style="width:100%;">
					<tr class="form-tr">
						<td class="form-th">项目名称:</td>
						<td class="form-td">
							<input class="easyui-textbox" name="entity.projectName" data-options="required:true"/>
						</td>
					</tr>
					<tr class="form-tr">
						<td class="form-th">一句话简介:</td>
						<td class="form-td">
							<input class="easyui-textbox" name="entity.introduction" data-options="required:true"/>
						</td>
					</tr>
					<tr class="form-tr">
						<td class="form-th">项目详情:</td>
						<td class="form-td">
							<input data-options="multiline:true" class="easyui-textbox" style="width: 80% ; height: 200%" name="entity.detail" data-options="required:true"/>
						</td>
					</tr>
					<tr class="form-tr">
						<td class="form-th">要求:</td>
						<td class="form-td">
							<input data-options="multiline:true" class="easyui-textbox" style="width: 80% ; height: 200%" name="entity.requireItem" data-options="required:true"/>
						</td>
					</tr>
					<tr class="form-tr">
						<td class="form-th">项目所属:</td>
						<td class="form-td">
							<input class="easyui-combogrid" name="entity.belongId" style="width:250px" data-options="
								panelWidth: 500,
								idField: 'id',
								textField: 'nickname',
								url: '/degua/project/detail/adminUserPage',
								method: 'post',
								columns: [[
									{field:'id',title:'id',width:80},
									{field:'nickname',title:'昵称',width:120},
									{field:'username',title:'用户名',width:120,align:'right'},
									{field:'phoneNumber',title:'手机号码',width:150,align:'right'},
									{field:'point',title:'积分',width:60,align:'center'},
									{field:'email',title:'邮箱',width:60,align:'center'}
								]],
								fitColumns: true
							"/>
						</td>
					</tr>
					<tr class= "form-tr">
						<td class= "form-th"><span style="color: red;">*</span>封面图片</td>
						<td class="form-td">
							<input type="hidden" id="cover_url" name="entity.coverUrl" >
                            <input id="file_upload_img" name="file_upload_img" type="button" value="上传">
						</td>
						<td class= "form-td" id="td_showImg">
							图片未上传
						</td>
					</tr>
					<tr class= "form-tr">
						<td class= "form-th"><span style="color: red;">*</span>其他附件</td>
						<td class="form-td">
                            <input id="file_upload_Othere" name="file_upload_Othere" type="button" value="上传">
						</td>
					</tr>
					<tr class= "form-tr">
						<td class="form-td" colspan="2" id="td_showFiles">
							
						</td>
					</tr>
					
					<tr class= "form-tr">
						<td colspan="2">
							<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" id="save_tag">保存</a>
							<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeWin();">取&nbsp;消</a>
						</td>
					</tr>
				</table>
			</form>
		</div>
		
	</div>
</body>
</html>